package com.baizhi.controller;

import com.baizhi.entity.CmfzGuru;
import com.baizhi.service.CmfzGuruService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
import java.util.logging.Logger;

/**
 * Created by Administrator on 2019/4/9 0009.
 */
@Controller
@RequestMapping("/guru")
public class CmfzGuruController {
    @Autowired
    private CmfzGuruService cmfzGuruService;
    private org.slf4j.Logger logger= LoggerFactory.getLogger(CmfzGuruController.class);

    @RequestMapping("/showAll")
    public @ResponseBody
    Map showAll(Integer page, Integer rows, String guruNickname) {
        Map map = cmfzGuruService.showAll(page, rows, guruNickname);
        return map;
    }

    @RequestMapping("/add")
    public @ResponseBody
    Map add(MultipartFile picture, CmfzGuru cmfzGuru, HttpServletRequest request) {
        Map add = cmfzGuruService.add(picture, cmfzGuru, request);
        return add;
    }

    @RequestMapping("/selectAll")
    public @ResponseBody
    Map selectAll() {
        Map map = cmfzGuruService.selectAll();
        return map;
    }

    @RequestMapping("/export")
    public void export(HttpServletResponse response) {
        cmfzGuruService.export(response);
    }

    @RequestMapping("/importGuruExcel")
    public @ResponseBody
    Map importGuruExcel(MultipartFile excelfile) {
        Map map = cmfzGuruService.importGuruExcel(excelfile);
        return map;
    }

    @RequestMapping("/frozen")
    public @ResponseBody Map frozen(Integer guruId){
        logger.debug("收到的数据{},",guruId);
        Map map = cmfzGuruService.frozen(guruId);
        return map;
    }

    @RequestMapping(value = "/unFrozen")
    public @ResponseBody Map unFrozen(Integer guruId){
        Map map = cmfzGuruService.unFrozen(guruId);
        return map;
    }
}
